package com.jugheadzhou.auth.core.message.producer.callback;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;

/**
 * 发生异常时的消息返回提醒
 *
 * @author jugheadzhou
 * @date 2021-12-03
 */
@Slf4j
public class RabbitDefaultReturnCallback implements RabbitTemplate.ReturnCallback {
    /**
     * Returned message callback.
     *
     * @param message    the returned message.
     * @param replyCode  the reply code.
     * @param replyText  the reply text.
     * @param exchange   the exchange.
     * @param routingKey the routing key.
     */
    @Override
    public void returnedMessage(Message message, int replyCode, String replyText, String exchange, String routingKey) {
        log.error("消息发送异常返回内容：\n消息主体: {}\n回复编码: {}\n回复内容: {}\n交换器: {}\n路由键: {}",
                message, replyCode, replyText, exchange, routingKey);
    }

}